#include <iostream>


void selectionSort( const int * const, const int );
void swap( const int * const, const int * );


void swap( int * const a, int * const b )
{
	int tmp;
	tmp = *b;
	*b = *a;
	*a = tmp;
}


void selectionSort( int * const vet, const int size )
{
	for( int i = 0; i < size - 1; i++ )
	{
		int min = vet[i];
		int k = i;
		for( int j = i + 1; j < size; j++ )
		{
			if( vet[j] < min )
			{
				min = vet[j];
				k = j;
			}
		}
		swap( &vet[k], &vet[i] );
	}
}


int main()
{
	const int arraySize = 10;
	int a[arraySize] = {2, 6, 4, 8, 10, 12, 89, 68, 45, 37};

	for( int i = 0; i < arraySize; i++ )
		printf( "%d ", a[i] );

	selectionSort( a, arraySize );

	printf("\n");
	for( int i = 0; i < arraySize; i++ )
		printf( "%d ", a[i] );

	printf("\n");
	return 0;
}
